package com.ruoyi.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
public class ChatController {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @GetMapping("/messages")
    public List<String> getMessages() {
        // 从Redis中获取消息列表
        return redisTemplate.opsForList().range("chatMessages", 0, -1);
    }
}
